﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserGrant.aspx.cs" Inherits="OA.Web.Authority.UserGrant" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>用户管理之授权</title>
    <link href="../Css/childindex.css" rel="stylesheet" type="text/css" />
    <link href="../Css/GridView.css" rel="stylesheet" type="text/css" />
    <link href="../Css/index.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/jscript">
        function $id(s) {
            return document.getElementById(s);
        }

        function copyToList(from, to) //from表示:包含可選擇專案的select物件名字 to表示:列出可選擇專案的select物件名字 //你可以根據你的具體情況修改
        {
            fromList = eval('document.forms[0].' + from);
            toList = eval('document.forms[0].' + to);
            if (toList.options.length > 0 && toList.options[0].value == 'temp') {
                toList.options.length = 0;
            }
            var sel = false;
            for (i = 0; i < fromList.options.length; i++) {
                var current = fromList.options[i];
                if (current.selected) {
                    sel = true;
                    if (current.value == 'temp') {
                        alert('不能选择这个角色!');
                        return;
                    }
                    txt = current.text;
                    val = current.value;
                    toList.options[toList.length] = new Option(txt, val);
                    fromList.options[i] = null;
                    i--;
                }
            }
            if (!sel) alert('未选择任何角色!');
        }

        function allSelect() //這是當使用者按下提交按鈕時，對列出選擇的select物件執行全選工作，讓遞交至的幕後程式能取得相關資料
        {
            List = document.forms[0].RoleList;
            if (List.length && List.options[0].value == 'temp') return;
            for (i = 0; i < List.length; i++) {
                List.options[i].selected = true;
            }
        }

        function getdata() {
            var List = document.forms[0].RoleList;
            var roles = $id("TRoleList");
            roles.value = "";
            var s = "";
            if (List.length != 0) {
                for (i = 0; i < List.length; i++) {
                    s += List.options[i].value + ",";
                }
            }

            roles.value = s;
        }
    </script>

</head>
<body>
       <form id="form1" runat="server">
        <table cellpadding="0" cellspacing="0" border="0" width="100%">
            <tr>
                <td>
                    <asp:Panel ID="TitlePanel" runat="server" CssClass="titlePadding">
                        给<asp:Label ID="UNAME" runat="server" ForeColor="Red"></asp:Label>授权<asp:Label ID="UID"
                            runat="server" Text="" Style="display: none;"></asp:Label>，<asp:Label ID="Label2"
                                runat="server" Text="允许和禁止都被选中或为空将删除该权限" ForeColor="#FF6600"></asp:Label>
                        <asp:Label ID="TID" runat="server" Text="" Style="display: none;"></asp:Label>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Panel ID="ChildPanel" runat="server" Visible="False">
                        <div class="rowdiv" style="margin-left: 3px;">
                            请选择授权类型：</div>
                        <div class="rowdiv">
                            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                                <asp:ListItem Value="1">用户角色</asp:ListItem>
                            </asp:DropDownList>
                        </div>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td>
                    <div id="strinfo" runat="server" class="mbox pbox" visible="false">
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="gv">
                        <asp:Panel ID="ModelPanel" runat="server">
                            <div style="float: left;">
                            </div>
                            <div style="float: left; margin-left: 10px;">
                                <div style="height: 24px; line-height: 24px; margin-top: 5px;">
                                </div>
                            </div>
                        </asp:Panel>
                        <asp:Panel ID="RolePanel" runat="server" Visible="true">
                            <table width="500" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
                                <tr>
                                    <td width="200" height="30" bgcolor="#CCCCCC">
                                        <div align="center">
                                            用户角色</div>
                                    </td>
                                    <td width="100" bgcolor="#CCCCCC">
                                        <div align="center" style="color: #FFFFFF;">
                                        </div>
                                    </td>
                                    <td width="200" bgcolor="#CCCCCC">
                                        <div align="center">
                                            系统角色列表</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td bgcolor="#FFFFFF">
                                        <div align="center" style="margin: 10px;">
                                            <asp:ListBox ID="RoleList" runat="server" Style="width: 160px;" SelectionMode="Multiple"
                                                Height="205px"></asp:ListBox>
                                            <asp:TextBox ID="OldRoleList" runat="server" Style="display: none;"></asp:TextBox>
                                            <asp:TextBox ID="TRoleList" runat="server" Style="display: none;"></asp:TextBox>
                                        </div>
                                    </td>
                                    <td bgcolor="#FFFFFF">
                                        <div align="center">
                                            <input id="btn_plus" type="button" value="   <<   " onclick="javascript:copyToList('FromRoleList','RoleList')" /><br />
                                            <br />
                                            <input id="btn_subtract" type="button" value="   >>   " onclick="javascript:copyToList('RoleList','FromRoleList')" /><br />
                                            <br />
                                            <asp:Button ID="btn_saverole" runat="server" Text=" 保 存 " OnClick="btn_saverole_Click" /><br />
                                            <br />
                                            按下CTRL鍵<br />
                                            可以多選
                                        </div>
                                    </td>
                                    <td bgcolor="#FFFFFF">
                                        <div align="center" style="margin: 10px;">
                                            <asp:ListBox ID="FromRoleList" runat="server" Style="width: 160px;" SelectionMode="Multiple"
                                                Height="205px"></asp:ListBox>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </asp:Panel>
                    </div>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
